#include<iostream>
using namespace std;
int main()
{
	long long m, n;
	while (cin >> m >> n)
	{
		while (m != n) {
			if (m > n) {
				m = m - n;
			 }
			else {
				n = n - m;
			}
		}
		cout << n << endl;
	}
	return 0;
}